package com.wwu.develop.generator;

import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.ITypeConvert;
import com.baomidou.mybatisplus.generator.config.po.TableField;
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
import com.wwu.develop.constant.SqlConst;

/**
 * @Description 类描述：数据库字段和java属性类型转换
 * @Author Administrator
 * @CreateTime 2020.03.26
 * @Version 1.0.0
 **/
public class SqlTypeConvert implements ITypeConvert {
    @Override
    public IColumnType processTypeConvert(GlobalConfig globalConfig, String fieldType) {
        String type = fieldType.toLowerCase();
        if(type.contains(SqlConst.DATE_TIME)){
            return DbColumnType.DATE;
        }else if(type.contains(SqlConst.VARCHAR)){
            return DbColumnType.STRING;
        }else if(type.contains(SqlConst.INT)){
            return DbColumnType.INTEGER;
        }
        return null;
    }

    @Override
    public IColumnType processTypeConvert(GlobalConfig globalConfig, TableField tableField) {
        return null;
    }
}
